Two chains of dollar stores in New York will pay $1.2 million to settle claims from the New York Attorney General's Office that they sold expired or obsolete products to customers, including medicine and motor oil, and failed to follow the state's bottle deposit law.

The settlement is the result of an undercover probe by investigators from the Attorney General's Office, which visited stores owned by Dollar General and Dollar Tree over a two-year period to scope out the misconduct.

New York Attorney General Letitia James said that, aside from the financial settlement, the agreement will ensure that neither chain continues to violate state law.

"It's a tough pill for New Yorkers to swallow that the over-the-counter drugs they were buying may have been expired," James said. "New York consumers have a right to expect that products on store shelves are safe, fresh and suitable for their advertised use."

Investigators found that several Dollar General, Dollar Tree and Family Dollar stores in New York had been selling over-the-counter drugs that were expired by months. It's illegal in New York to sell over-the-counter drugs past the date marked on the product's label.

At Dollar General, investigators also found store-brand motor oil that was obsolete, including oil that hasn't been suitable for most engines for decades, according to the Attorney General's Office. Those products were placed next to other brands that were fine for modern engines and excluded any warning about their use.

While Dollar General conceded Monday that it took immediate action to address medication that was past its expiration date, the company said in a response that it disagreed with investigators about the motor oil.

"We continue to believe that the DG-branded motor oil products at issue meet both the Company's standards for quality and value, but also all applicable federal and state labeling, marketing and placement requirements where they are sold," the company said.

Investigators also found that Dollar Tree and Family Dollar stores were not complying with a section of state law that requires retail stores to accept certain beverage containers for redemption. When they tried to bring compliant bottles to those stores, they were told that the store either didn't accept deposits or needed a proof of purchase, according to the office.

Dollar Tree, which owns Family Dollar, did not immediately return a request for comment Monday.

As part of the settlement, both chains agreed to create a system to track the expiration dates on merchandise delivered to their distribution centers, inspect and restock store shelves regularly, and conduct monthly audits of each store to check for expired products.

Each chain will also be subject to third-party audits at 10% of their stores in New York for at least a year.

Dollar General agreed to pay $1.1 million in restitution, damages, penalties and costs as part of the settlement. Dollar Tree agreed to pay $100,000.

Dollar General was represented by Noreen Kelly, a partner at McGuireWoods. Dollar Tree and Dollar Family were represented by Ronald Blum, a partner at Manatt, Phelps & Phillips.

READ MORE: